﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace canyinguanlixitong
{
    public partial class frmaddsever : Form
    {
        public frmaddsever()
        {
            InitializeComponent();
        }
        string strconn = "Data Source=.;Initial Catalog=Supermarket management system;Integrated Security=True";
        private void frmaddsever_Load(object sender, EventArgs e)
        {

        }
        public void add()
        {
            SqlConnection conn = new SqlConnection(strconn);
            conn.Open();
            int djbh =Convert.ToInt32(this.textBox1.Text);
            string dj = this.textBox2.Text;
            string sql = "insert into fws(fwsbh,fwsdj)  values('"+djbh+"','"+dj+"')";
            SqlCommand cmd = new SqlCommand(sql,conn);
            int i = cmd.ExecuteNonQuery();
            if (i==1)
            {
                MessageBox.Show("增加成功");
            }
            else
            {
                MessageBox.Show("增加失败");
            }
            
            conn.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            add();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
